package com.kotlinvben.bean

data class PageData<T>(
    val items: List<T>,
    val total: Long,
    val page: Int,
    val size: Int,
    val pages: Int
) {
    companion object {
        fun <T> of(items: List<T>, total: Long, page: Int, size: Int): PageData<T> {
            val pages = if (total % size == 0L) (total / size).toInt() else (total / size + 1).toInt()
            return PageData(
                items = items,
                total = total,
                page = page,
                size = size,
                pages = pages
            )
        }
    }
} 